﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Library.Linq.Search
{
    public interface ISearchProvider
    {
        ISearchable CreateSearch(Expression expression);
        ISearchable<TSearch, TResult> CreateSearch<TSearch, TResult>(Expression expression);
        object Execute(Expression expression);
        TResult Execute<TResult>(Expression expression);
    }

    public interface ISearchable
    {
        Type SearchType { get; }
        Type ElementType { get; }
        Expression Expression { get; }
        ISearchProvider Provider { get; }

        IEnumerator GetEnumerator();
    }

    public interface ISearchable<out TSearch, out TResult> : ISearchable
    {
        new IEnumerator<TResult> GetEnumerator();
    }

    public interface IOrderedSearchable : ISearchable { }

    public interface IOrderedSearchable<out TSearch, out TResult> : ISearchable<TSearch, TResult>, IOrderedSearchable { }
}
